﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ElingOA6_Admin_DSJCJ.Common;

namespace ElingOA6_Admin_DSJCJ.Areas.Admin.Controllers
{
      [OutputCache(Duration = 0, VaryByParam = "none")]
    public class FTPShowTextController : Controller
    {
        //
        // GET: /Admin/FTPShowText/
        private BLL.Entity EntityBLL = new BLL.Entity();
        [AuthorityActionFilter("m_FTPShowText", Order = 1)]
        [LogPageActionFilter("文件上传说明", Order = 2)]
        public ActionResult Index()
        {
            string entityNo = GlobalConstant.ENTITYNO;
            Model.Entity EntityModel = EntityBLL.GetModel(entityNo);
            if (EntityModel!=null)
            {
                if (!string.IsNullOrEmpty(EntityModel.FFtpShowText))
                {
                    EntityModel.FFtpShowText = EntityModel.FFtpShowText.Replace("<br/>", "\r\n");
                }
            }
           

            return View("Index", EntityModel);
        }
        [HttpPost]
        [ValidateInput(false)]
        public ActionResult SavaModel(Model.Entity entityModel)
        {
            try
            {
                if (string.IsNullOrEmpty(entityModel.FFtpShowText))
                {
                    ViewData["jsAlert"] = "错误代码:内容不能为空";
                    return View("Index", new Model.Entity());
                }
                else
                {


                    entityModel.FFtpShowText = entityModel.FFtpShowText.Replace("\r\n\r\n", "<br/>");
                    string entityNo = GlobalConstant.ENTITYNO;
                    Model.Entity EntityModel2 = EntityBLL.GetModel(entityNo);
                    EntityModel2.FFtpShowText = entityModel.FFtpShowText;
                    EntityBLL.UpdateEntity(entityNo, EntityModel2);
                    ViewData["jsAlert"] = "保存成功";
                    return View("Index", entityModel);
                }
            }
            catch (System.Exception ex)
            {
                ViewData["jsAlert"] = "错误代码:" + ex.Message.ToString();
                return View("Index", new Model.Entity());
            }
        }

    }
}
